import {
  request
} from '../utils/request';

// 解密绑定手机号
const decryptPhone = (encryptedData, iv) => {
  return request({
    url: '/user/phone',
    method: 'POST',
    data: {
      encryptedData: encryptedData,
      iv: iv
    }
  });
}

// 解密手机号
const bindPhone = (encryptedData, iv) => {
  return request({
    url: '/user/encryptedPhone',
    method: 'POST',
    data: {
      encryptedData: encryptedData,
      iv: iv
    }
  });
}

// 用户信息
const userInfo = () => {
  return request({
    url: '/user/info'
  });
}

// 修改用户信息
const editUserInfo = (data = {}) => {
  return request({
    url: '/user/edit',
    method: 'POST',
    data: data
  });
}

// 单位列表
const unitList = () => {
  return request({
    url: '/unit/list'
  });
}

// 用户订单列表
const orderList = (nav, pageNum, pageSize) => {
  return request({
    url: `/customer/order/list/${nav}`,
    data: {
      pageNum: pageNum,
      pageSize: pageSize
    }
  });
}

// 订单详情
const orderDetails = (orderNo) => {
  return request({
    url: `/customer/order/${orderNo}`
  });
}

// 订单支付
const orderPayment = (orderNo) => {
  return request({
    url: `/order/pay/${orderNo}`
  });
}

// 订单查询
const orderQuery = (orderNo) => {
  return request({
    url: `/order/query/${orderNo}`
  });
}

// 订单取消
const orderCancel = (orderNo) => {
  return request({
    url: `/customer/order/cancel/${orderNo}`
  });
}

// 新闻收藏列表
const newsCollectList = (pageNum, pageSize) => {
  return request({
    url: '/news/collect/list',
    data: {
      pageNum: pageNum,
      pageSize: pageSize
    }
  });
}

// 核销-活动详情
const verifierActivity = (orderNo) => {
  return request({
    url: `/verifier/activity/${orderNo}`
  });
}

// 核销
const writeOff = (orderNo) => {
  return request({
    url: `/verifier/writeOff/${orderNo}`
  });
}

// 核销记录
const writeOffList = (pageNum, pageSize) => {
  return request({
    url: '/verifier/writeOff/list',
    data: {
      pageNum: pageNum,
      pageSize: pageSize
    }
  });
}

// 客服
const customerService = () => {
  return request({
    url: '/link/list'
  });
}

// 红点提示
const orderTips = () => {
  return request({
    url: '/user/dashBoard'
  });
}

module.exports = {
  bindPhone,
  decryptPhone,
  userInfo,
  editUserInfo,
  unitList,
  orderList,
  orderDetails,
  orderPayment,
  orderQuery,
  orderCancel,
  newsCollectList,
  verifierActivity,
  writeOff,
  writeOffList,
  customerService,
  orderTips
}